<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Details mondat</title>


<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form css ----------------------->
	<link href="<?php echo base_url("assets/css/pure.css")?>" rel="stylesheet" type="text/css" />
<!---------------------for form validation ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.validate.js');?>" ></script>
<!---------------------for form mask input ----------------------->
<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.mask.min.js');?>" ></script>

 <link href="<?php echo base_url("assets/css/botton.css")?>" rel="stylesheet" type="text/css" />
 
</head>
<body>
<?php
include_once('header.php');
$r1=$results;  // one fournisseur


// ----- populate $liste_des_fournisseurs array for autocomplete ----- //
$liste_des_fournisseurs = array();
foreach ($fournisseurs as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
}
// ----- populate $liste_des_activites array for autocomplete ----- //

?>
<?php
echo form_open_multipart( base_url('mondat_ctr/update').'/'.$r1[0]->id_mandat ); 


?>

<form id="fournisseur_frm" class="pure-form pure-form-stacked" method="POST" action="<?php echo base_url('facture_ctr/update').'/'.$r1[0]->id_mandat ;?>">
    <fieldset>
        <legend>رقم حوالة دفع: <?php echo('<strong>'.$r1[0]->num_mondat.'</strong>');?></legend>

        <div class="pure-g">
            <div class="pure-u-1 pure-u-md-1-3">
                <label for="fournisseur">المورد </label>
				<input id="nom" name="fournisseur" type="text" value="<?php echo($r1[0]->fournisseur);?>">
            </div>
<?php
if($r1[0]->id_bc )
    echo('        <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="article">وصل الطلب </label>
                <input  class="ltr" id="bc" name="bc" type="text" value="'.$r1[0]->numero_bc.'">
            </div>');
else echo('        <div class="pure-u-1 pure-u-md-1-3 ">
                <label for="article">الاتفاقية</label>
                <input  class="ltr" id="bc" name="bc" type="text" value="'.$r1[0]->numero_convetion.'">
            </div>');
?>
            <div class="pure-u-1 pure-u-md-1-3 " style="width: 30%">
                <label for="numero"> رقم الصك</label>
				<input class="ltr" id="numero" name="cheque" type="text" value="<?php echo($r1[0]->numero_cheque);?>">
                
            </div>

           
			
			<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="address">التاريخ </label>
                <input id="montant" name="date" type="text" value="<?php echo($r1[0]->date);?>">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="address">رقم الفاتورة </label>
                <input id="montant" name="facture" type="text" value="<?php echo($r1[0]->id_facture);?>">
            </div>
			
			<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="address">المبلغ </label>
                <input id="montant" name="montant" type="text" value="<?php echo($r1[0]->montant_fact);?>">
            </div>
			
			<?PHP
			if($r1[0]->visa_cf){
				echo('<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="address">تأشيرة المراقب المالي </label>
                <input id="montant" name="montant" type="text" value="'.$r1[0]->visa_cf.'">
            </div>
			<div class="pure-u-1 pure-u-md-1-3" style="width: 30%">
                <label for="address">تاريخ تأشيرة المراقب المالي </label>
                <input id="montant" name="montant" type="text" value="'.$r1[0]->date_visa_cf.'">
            </div>
			');
			}
			?>
			
        </div>
      <?php
  $goupe=$this->session->userdata('user_group'); //access it
if($goupe=="admin"){
echo ('<a href="'. base_url('mondat_ctr/update').'/'.$r1[0]->id_mandat.'" class="pure-button pure-button-primary">تحديث</a>
<a href="'. base_url('mondat_ctr/accord_cf').'/'.$r1[0]->id_mandat.'" class="pure-button pure-button-primary">موافقة المراقب المالي</a>
');
}else{
	echo ('<a href="#" class="pure-button-disabled pure-button-primary">تحديث</a>');
}
?>
     <!-- <input type="submit" value="تحديث"  class="pure-button pure-button-primary" />-->
      <a href="<?php echo base_url("/mondat_ctr/")?>" class="pure-button pure-button-primary">خروج</a>
       <a href="<?php echo base_url("/mondat_ctr/imprimer_mondat").'/'.$r1[0]->id_mandat?>" class="pure-button pure-button-primary">طباعة</a>
    
    </fieldset>
</form>

<?php  
if($goupe=="finance"){ // si il est comtable on affiche des bottons
  if(!$r1[0]->visa_compta)
	 echo '
 <div>
 <form id="bc_form"  method="POST" action="'.base_url('mondat_ctr/valider_accord_comptable').'/'.$r1[0]->id_mandat.'">
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%; text-align: center; letter-spacing:0.5px; font-size:150%">
                <label for="numero" > خاص بالمحاسب</label>
			
                
            </div>
			<br><br><br><br><br>
			
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero"> رقم التاشيرة </label>
				<input class="ltr" id="visa_comptabe" name="visa_comptable" type="text" value="">
                
            </div>
			<br><br>
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero"> رقم الصك </label>
				<input class="ltr" id="num_cheque" name="num_cheque" type="text" value="">
                
            </div>
			<br><br>
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero"> التاريخ</label>
				<input class="ltr" id="date" name="date" type="text" value="">
                
            </div>
			<br><br>
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero"> رقم الصفحة </label>
				<input class="ltr" id="page" name="page" type="text" value="">
                
            </div>
			<br><br><br>
			<div class="pure-u-1 pure-u-md-1-3 " style="width: 90%">
                <label for="numero">ligne</label>
				<input class="ltr" id="ligne" name="ligne" type="text" value="">
                
            </div>
			
			
			
			<div  class="pure-u-1 pure-u-md-1-3" " style="width: 90%">
		<input type="submit" id="ajouter" value="دفع"  class="pure-button pure-button-primary"  />
	 
			 </div>
			 </form>
			 </div>
			';
			
	}
	
	?>
</body>
<script>
$(function() {
	

var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;


$( "#nom" ).autocomplete({source: liste_fourniss});



});

//---

$('#submit_btn').click(function() {
  if($("[class^=error]").is(":visible")){
    alert('منالك حقل / حقول إدخال غير مطابقة !');
    return false;
  } else {
  	$('#fournisseur_frm').submit();
    return false;
  }
});


$('#numero').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]{1,3})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});
$('#mondat').bind('mouseup keyup focusout focus mousemove',function() {
    $('span.error-rc').hide();
	$(this).css('background-color','pink');
    var inputVal = $(this).val();
    //var characterReg = /^([a-zA-Z0-9]{7,16})$/;
    var characterReg = /^([0-9]{1,3})$/;
    if(!characterReg.test(inputVal)) {
        $(this).after('<span class="error-rc" flag="required" style="color:red;" >حقل غير مطابق للشكل العام </span>');
    }else{
		$(this).css('background-color','#FFFFFF');
	}
});




//---* maskage below 
$('#numero').mask('AAA', {'translation': {
                                        A: {pattern: /[0-9]/},
										O: {pattern: /[0-9]/, optional: true},
										D: {pattern: /[a-zA-Z]/}
                                      }
                                });

//---* maskage below 
$('#mondat').mask('AAA', {'translation': {
                                        A: {pattern: /[0-9]/},
										O: {pattern: /[0-9]/, optional: true},
										D: {pattern: /[a-zA-Z]/}
                                      }
                                });





</script>
</html>